#ifndef __SCNS_MENU_H__
#define __SCNS_MENU_H__

#include "ScnsConfig.h"

#if defined(SCNS_MENU_ENABLE)&&SCNS_MENU_ENABLE==1

#include "ScnsBspMenu.h"

#include "ScnsYing.h"

typedef enum
{
    SCNS_MENU_MODE_KEY=(1<<0),
    SCNS_MENU_MODE_SMCTP=(1<<1),
    SCNS_MENU_MODE_LCD=(1<<2),
}ScnsMenuMode;

typedef enum
{
    SCNS_MENU_STATUS_OK=SCNS_YING_STATUS_OK,
    SCNS_MENU_STATUS_BSP_FAILED=SCNS_YING_STATUS_BSP_FAILED,
    SCNS_MENU_STATUS_FAILED=SCNS_YING_STATUS_FAILED,
    SCNS_MENU_STATUS_CONFIG_ERROR,
}ScnsMenuStatus;

extern uint8 scnsMenuCanPageSend(uint8 page);
extern uint8 scnsMenuCanPageDisplay(uint8 page);

extern ScnsMenuStatus scnsMenuInit(void);
extern void scnsMenuAddTest(uint8 page);
#define scnsMenuAdd(page,field,namePrefix,type,canModify,savePage,smallStep,bigStep)                       scnsMenuAddWithName(page,#field namePrefix,(void*)(&(field)),type,canModify,savePage,smallStep,bigStep)
#define scnsMenuAddConst(page,field,namePrefix,type)                                                       scnsMenuAddWithName(page,#field namePrefix,(void*)(&(field)),type,0,0XFFFF,0,0)
#define scnsMenuAddStruct(page,preStruct,field,namePrefix,type,canModify,savePage,smallStep,bigStep)       scnsMenuAddWithName(page,namePrefix #field,(void*)(&((preStruct).field)),type,canModify,savePage,smallStep,bigStep)
#define scnsMenuAddConstStruct(page,preStruct,field,namePrefix,type)                                       scnsMenuAddWithName(page,namePrefix #field,(void*)(&((preStruct).field)),type,0,0XFFFF,0,0)
#define scnsMenuAddFunction(page,f)                                                                        scnsMenuAddWithName(page,#f,(void*)(f),SCNS_TYPE_FUNCTION,0,0XFFFF,0,0)
extern uint16 scnsMenuAddWithName(uint8 page,const char*name,void*p,ScnsType type,uint8 canModify,uint16 savePage,float smallStep,float bigStep);
extern void scnsMenuSetCanModify(uint16 i,uint8 canModify);
extern uint8 scnsMenuGetNowPage(void);
extern void scnsMenuSetNowPage(uint8 page);
extern void scnsMenuSetMode(ScnsMenuMode mode);
extern void scnsMenuPrintPage(uint8 page);
extern void scnsMenuSetPage(uint8 page,const char*name,uint8 (*updateCallback)(void*));
extern void scnsMenuReceiveInterrupt(const uint8*buf,uint32 length);
extern void scnsMenuFresh(void);

#if defined(SCNS_KEY_ENABLE)&&SCNS_KEY_ENABLE==1

#include "ScnsKey.h"

extern void scnsMenuHandleKey(ScnsKeyMsg key);
#endif
#endif
#endif
